class Storge{
	get(key){
		const value = uni.getStorageSync(key);
		if(value){
			const data = JSON.parse(value);
			const now = new Date().getTime();
			if(typeof data['__expire__'] == 'number' && data['__expire__'] < now){
				this.remove(key);
				return {
					message:`${key}的缓存已过期`,
					value:null
				};
			}else{
				return {
					message:`成功`,
					value:data.value
				}
			}
		}else{
			return {
				message:`没有找到${key}的缓存`,
				value:null
			}
		}
		
	};
	set(key,value,expire = 'permanent'){  //key:缓存名称  value:缓存值   expire:缓存时间
		
		const data = {
			value,
			"__expire__":expire
		};
		console.log('data=>',data);
		uni.setStorageSync(key,JSON.stringify(data))
	};
	remove(key){
		uni.removeStorageSync(key);
	};
	clear(){
		uni.clearStorageSync()
	};
}
export default new Storge();